package mysql

import "gorm.io/gorm"

type Image struct {
	gorm.Model
	HouseId int    `gorm:"type:varchar(20);not null;comment:'房源Id'"`
	Url     string `gorm:"type:varchar(500);not null;comment:'地址'"`
	Name    string `gorm:"type:varchar(10);not null;comment:'标题'"`
}

type Order struct {
	gorm.Model
	UserId      int     `gorm:"type:varchar(20);not null;comment:'用户Id'"`
	HouseId     int     `gorm:"type:varchar(20);not null;comment:'房源Id'"`
	OrderSn     string  `gorm:"type:varchar(50);not null;comment:'订单编号'"`
	Pay         int     `gorm:"type:tinyint(1);default:1;not null;comment:'支付方式:1-支付宝 2-微信'"`
	OrderStatus int     `gorm:"type:tinyint(1);default:1;not null;comment:'订单状态:1-未支付 2-已支付'"`
	Amount      float64 `gorm:"type:decimal(10,2);not null;comment:'总价格'"`
}

func (o *Order) Update(orderSn string, status int) error {
	return DB.Debug().Model(&o).Where("order_sn=?", orderSn).Update("order_status", status).Error
}
